// @ts-nocheck
import texttoaudio from '@service.texttoaudio'


/**
 * 播放英文单词
 * @param {string} word 英文单词
 */
const speak = (word) => {
    return new Promise((resolve, reject) => {
        if(texttoaudio.isSpeaking()) {
            texttoaudio.stop();
        }
        texttoaudio.speak({
            lang: 'en_US',
            content: word,
            pitch: 1,
            rate: 1,
            success: function (data) {
                resolve(data.utteranceId);
            },
            fail: function (data, code) {
                reject({
                    err_code: code,
                    err_msg: data
                });
            }
        })
    });
}

export default {
    speak
}